;; The first four lines of this file were added by Dracula.
;; They tell DrScheme that this is a Dracula Modular ACL2 program.
;; Leave these lines unchanged so that DrScheme can properly load this file.
#reader(planet "reader.rkt" ("cce" "dracula.plt") "modular" "lang")
(require "Ihelpers.lisp")

(module Mhelpers
  (include-book "io-utilities" :dir :teachpacks)
  (include-book "list-utilities" :dir :teachpacks)
  
  ; takes a list of a list of words in char representation
  ; and turns it into a list of words in string representation
  (defun chrs-words->strings (words)
    (if (consp words)
        (cons (chrs->str (car words)) (chrs-words->strings (cdr words)))
        nil))
  
  ; returns the maximum in the list of stocks
  ; and their statistics for performance and volume
  ; queries
  (defun get-max (stocks currmax)
    (if (consp stocks)
        (let* ((currTicker (caar stocks))
               (currStat (cadar stocks))
               (maxTicker (car currmax))
               (maxStat (cadr currmax)))
          (if (> currStat maxStat)
              (get-max (cdr stocks) (car stocks))
              (get-max (cdr stocks) currmax)))
        currmax))
  
  ; returns the sum of all the elements of a list
  (defun sum-list (list)
    (if (consp list)
        (+ (car list) (sum-list (cdr list)))
        0))
  
  ; returns the average value in a list
  (defun average-list (list)
    (if (consp list)
        (/ (sum-list list) (length list))
        nil))
  
  (export Ihelpers))